; Startup file for Star
;commented version

{Print
;Print one or more text files
;Files may have type Text,Exec or Obey
;They are headed by the file name in emphasised type
;If your printer is not Epson compatible you may have to change the codes
;This also depends on the line feed settings you use.
:Print
(
#? FFF FFE FEB
*echo <27>G<27>E********   %?<27>F<27>H<10><10> { > printer: }
*copy %? printer: ~c ~v
*echo <10><10> { > printer: }
)  

;Print as above with a bannner 
;This shows how to pass parameters to a BASIC program
;The program "flag" must be somewhere on Run$Path
;Note how the *if line ensures that the banner does not contain more than 
; 16 characters
;flag may need altering for your printer.

:BPrint
(
#? FFF FFE FEB
*set p1 %<>?.%>?
*if LEN p1 >16 then set p1 %>?
*flag { > printer: }
*copy %? printer: ~c ~v
*echo <10><10> { > printer: }
)

:Open
*Filer_OpenDir printer:
}

;These open some useful applications and this weeks games.
;The application directories are set up in system:!Boot and you will need to 
; change them
{Apps
:Edit
*Run <Apps$Dir>.Eds.!Edit
:Ed
*Run <Apps$Dir>.Eds.!Ed
:Alarm
*Run <Apps$Dir>.Useful.!Alarm
:Taipei
*run <Root$Dir>.Games.Board.!Taipei
:Patience
*run <Root$Dir>.Games.Board.!Patience
}

{Other
:startext
|*Filer_opendir <Star$Dir>.StarText
{Show
:FileType
*Show File$Type*
:Alias
*Show Alias$*
:Keys
*Show Key*
:Paths
*Show *$Path
:Dirs
*Show *$Dir
}
; Only useful if you have a Watford scanner.
; I keep mine rmkilled as the scanloader slows down other applications.
:Scan
*rmreinit scanloader
*startscan
}

{Files
;Set current directory - to root by default
;needs <Root$Dir> set up in system:!boot
:Dir
<0 <Root$Dir>
#0 1000 2000 123456
*dir %0

:Info
[
(
*Info %?
)
]

;Wipe the disk in drive :0
;Note the Query !!
:Wipe :0
*Filer_opendir adfs::0.$
? Do you really want to wipe disk in :0
*Wipe ADFS::0.$ ~CFR~V
}

{Comm

;Start up non-wimp program
;The wimpslot choices are a bit arbitrary you may need to be careful with
; them if you are short of memory
;Note the *wimpslot would have no effect if it was not bracketed with
; the *arcterm by [].
:Arcterm
*rmkill internationalkeyboard
[
*dir <Root$Dir>
*urd $.Comm
*Wimpslot -min 640k -max 1024k
*arcterm -rcomm
]
*rmreinit internationalkeyboard

:ToArc
(
*settype %? DDC
)

:ToText
(
*settype %? FFF
)

:OpenSpl
|*Filer_OpenDir <Root$Dir>.Comm.SPL

}

{Basic
;load a BASIC program into the editor
;sets the current directory to the one the program came from
;so you can save using REM >Progname - without a pathname
;Needs to find the BasicEdit module. I keep it in module:
; module: is defined in system:!Boot
;Sets up some useful function keys
;F12 returns to desktop
;Print Prints!
;If you have the PCOL multi-column printing utility on Run$Path
; F11 accesses it.

:Edit
#0 FFB
*DIR %<0
*RMensure ARMBasicEditor 1.00 RMload Module:BasicEdit
*KEY 0 LISTO 1|M LIST |B|O|M|C
*KEY 1 EDIT |M
*KEY 2 RUN|M
*KEY 3 SAVE|M
*KEY 4 LVAR|M
*KEY 11 *PCOL|M
*KEY12 |C|O*QUIT|M
|+EDIT|M
*BASIC -LOAD %0

;As above but starts a new program. Drag a directory to put it in or accept
; the default. You may want to change the default.

:New
<0 $
#0 1000 2000 123456
*DIR %0
*RMensure ARMBasicEditor 1.00 RMload Module:BasicEdit
*KEY 0 LISTO 1|M LIST |B|O|M|C
*KEY 1 EDIT |M
*KEY 2 RUN|M
*KEY 3 SAVE|M
*KEY 4 LVAR|M
*KEY 11 PCOL|M
*KEY12 |C|O*QUIT|M
|+EDIT|M
*BASIC

;Turn BASIC to text and load into editor
;Listing is put in <Star$Scrap>.leafname
;This is loaded into an editor and the unwanted first and last lines deleted
;the |+<&88> ... line does the deleting in Ed
;For edit you will need something like
;
;If you dont like line numbers change the LISTO option

:BAStoTXT
#0 FFB
|+LISTO 1|M*SPOOL <Star$Scrap>.%>0|MLIST|M*SPOOL|MQUIT|M
*BASIC -LOAD %0
*settype <Star$Scrap>.%>0 FFF
><Star$Scrap>.%>0
|+<&88><&AE><&8F><&8F><&88><&AF>

;Turn text to BASIC
;Unfortunately applying BAStoTXT and TXTtoBAS adds extra spaces
;after the line numbers
;If you dont use line numbers use AUTO and LOAD

:TXTtoBAS
#0 FFF
|+*EXEC %0|MSAVE "<Star$Scrap>.%>0"|MQUIT|M
*BASIC
}


;The next submenu consists of utilities for C programming
;The system variable <C$Dir> needs to be set to the directory
; that contains your c,h,o directories and makefile.
; E.g your application directory
;You can set this in system:!Boot while working on one project
; or drag the directory to star and use :Set C$Dir if you are doing
; several at once

{C
;Make the first thing in your makefile.
;See !Star.makefile for an example
;1Mb users may need to juggle the wimpslot
; and to use the amu -o option and then obey the file

:Make
[
*dir <C$Dir>
*RMEnsure SharedCLibrary 1.02 RMLoad System:Modules.CLib
*wimpslot -min 640k -max 1024k
*amu -i
]

;make the :tidy thing in your makefile.
;see !Star.makefile for an example

:Tidy
[
*dir <C$Dir>
*wimpslot -min 320k -max 640k
*amu tidy
]

:Set C$Dir
#0 1000 2000
*set C$Dir %0

:Open c
|*Filer_OpenDir <C$Dir>.c

:Open h
|*Filer_OpenDir <C$Dir>.h

;update the datestamps of .o. files
;useful if you have added a new global to a header file
;and dont want make to recompile files that dont use it
;Note you can drag .c. files to star, Touch updates the
; corresponding .o. files

:Touch
#! FFF FED
(
*stamp %<<?.o.%>?
)
;The next three options run some unix type utilities from
;David Pilling's disks. Mkid constructs an identifier database
;Lid looks up an identifier in the database.
;Lid uses a database for the RISC_OSlib headers as a default.
;You will have to costrust this with mkid and set its directory name.
;Compare compares two files !
;You will need lid,mkid and fc to be on Run$Path

:Lid
<0<Root$Dir>.arm.RISC_OSlib.id
#0 FFD 123456
[
*wimpslot -min 128k -max 640k
*lid -f%0 %"Search for identifier?"
]

:Mkid
<0 <C$Dir>
#0 1000 2000 123456
[
*dir %0
*wimpslot -min 320k -max 640k
*mkid -v c.* h.*
*settype id FFD
]

:Compare
[
*wimpslot -min 128k -max 640k
*echo |N |Z |L
*fc %0 %1 F TR
]
}
